﻿<phone:PhoneApplicationPage 
    x:Class="Coding4Fun.FakeCall.SettingPivot"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:sl="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
	xmlns:clr="clr-namespace:ClearableTextBox;assembly=ClearableTextBox" 
	xmlns:Converters="clr-namespace:Coding4Fun.FakeCall.Converters"
    xmlns:Toolkit="clr-namespace:Coding4Fun.Phone.Controls.Toolkit;assembly=Coding4Fun.Phone.Controls.Toolkit"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait">
	<phone:PhoneApplicationPage.Resources>
		<Converters:InverseBoolToVisibilityConverter x:Key="InverseBoolToVisibilityConverter" />
		<Converters:HasStringToVisibilityConverter x:Key="HasStringToVisibilityConverter" />
		<Converters:ImageConverter x:Key="ImageConverter" />
		<Style x:Name="descItems" TargetType="TextBlock">
			<Setter Property="Margin" Value="12,10,0,-5" />
			<Setter Property="Foreground" Value="{StaticResource PhoneSubtleBrush}" />
		</Style>
		<Style x:Name="descSwitch" TargetType="sl:ToggleSwitch">
			<Setter Property="Margin" Value="0,10,0,-25" />
		</Style>

		<Style x:Key="photoStyle" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Border 
								VerticalAlignment="Top" 
								BorderThickness="1" 
								BorderBrush="{StaticResource PhoneForegroundBrush}" 
								Height="275" Width="175" 
								Margin="0,12,0,12">
							<Grid>
								<Rectangle Fill="Transparent" Opacity="0" />
								<ContentPresenter />
								<TextBlock 
									Style="{StaticResource descItems}"
									FontSize="{StaticResource PhoneFontSizeLarge}" 
									RenderTransformOrigin="1,1" 
									VerticalAlignment="Center" 
									HorizontalAlignment="Right">
									<TextBlock.RenderTransform>
										<CompositeTransform Rotation="-90" />
									</TextBlock.RenderTransform>
									Picture
								</TextBlock>
							</Grid>
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		
		<ControlTemplate x:Key="clearX" TargetType="Button">
			<Grid HorizontalAlignment="Right"
				VerticalAlignment="Center">
				<Rectangle Fill="Red" Opacity="0" />
				<Image 
					Margin="10,10"
					Stretch="None" 
				Source="/Coding4Fun.FakeCall;component/Media/appbar.close.rest.png" />
			</Grid>
		</ControlTemplate>
	</phone:PhoneApplicationPage.Resources>
		<!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!--Pivot Control-->
        <controls:Pivot Title="FAKE CALL SETTINGS">
            <!--Pivot item one-->
            <controls:PivotItem Header="General">
				<StackPanel Margin="0,-30,0,0">
					<TextBlock Style="{StaticResource descItems}">
						Call Delay
					</TextBlock>
					<Toolkit:TimeSpanPicker 
						Name="timeDelay"
						Value="{Binding TimeSpan10Second}"
						Max="{Binding TimeSpan59Min}"  />
					<sl:ToggleSwitch 
						Name="generalShowAllSettings"
						Style="{StaticResource descSwitch}"
						Header="Customize All Settings"
						IsChecked="{Binding Settings.CustomizeSettings, Mode=TwoWay}" />
					<StackPanel Name="generalMisc"
						Visibility="{Binding Settings.CustomizeSettings, Converter={StaticResource InverseBoolToVisibilityConverter}}" >
						<sl:ToggleSwitch 
							Name="generalRing"
							Style="{StaticResource descSwitch}"
							 Header="Ring"
							IsChecked="{Binding Settings.RingPhone, Mode=TwoWay}" />
						<sl:ToggleSwitch 
							Name="generalVibrate"
							Style="{StaticResource descSwitch}"
							Header="Vibrate"
							IsChecked="{Binding Settings.VibratePhone, Mode=TwoWay}" />
						<sl:ToggleSwitch 
							Name="generalExpandTalkOptions"
							Style="{StaticResource descSwitch}"
							Header="Expand Talk Options On Answer"
							IsChecked="{Binding Settings.ExpandTalkOptions, Mode=TwoWay}" />
					</StackPanel>
				</StackPanel>
			</controls:PivotItem>

            <!--Pivot item two-->
			<controls:PivotItem 
				Header="Lock Screen" 
				Name="lockScreen" 
				IsEnabled="{Binding Settings.CustomizeSettings}">
				<StackPanel Margin="0,-30,0,0">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="* "/>
							<ColumnDefinition Width="* "/>
						</Grid.ColumnDefinitions>
						<StackPanel Grid.Column="0">
							<TextBlock Style="{StaticResource descItems}">
								Display Date
							</TextBlock>
							<sl:DatePicker
								Name="lockDisplayDate"
								Value="{Binding Settings.LockScreenDate, Mode=TwoWay}"
								/>
							<TextBlock Style="{StaticResource descItems}">
								Display Time
							</TextBlock>
							<sl:TimePicker 
								Name="lockDisplayTime"
								Value="{Binding Settings.LockScreenTime, Mode=TwoWay}"/>
						</StackPanel>

						<Button 
							Click="newLockScreenPhoto_Click"
							Grid.Column="1" 
							Style="{StaticResource photoStyle}">
							<Image 
								Name="lockScreenPhoto"
								Source="{Binding Settings.LockScreenPhoto, 
								Converter={StaticResource ImageConverter}}" 
								Stretch="UniformToFill" />
						</Button>
					</Grid>
					<StackPanel Margin="0,-40,0,0">
						<TextBlock Style="{StaticResource descItems}">
							Appointment
						</TextBlock>
						<clr:ClearableTextBox 
							Name="lockAptName"
							Text="{Binding Settings.AppointmentName, Mode=TwoWay}"
							ClearButtonTemplate="{StaticResource clearX}" />
						<StackPanel Visibility="{Binding ElementName=lockAptName, Path=Text, Converter={StaticResource HasStringToVisibilityConverter}}" >
							<TextBlock Style="{StaticResource descItems}">
								Location
							</TextBlock>
							<clr:ClearableTextBox 
								Name="lockAptLocation"
								Text="{Binding Settings.AppointmentLocation, Mode=TwoWay}"
								ClearButtonTemplate="{StaticResource clearX}" />
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="* "/>
									<ColumnDefinition Width="* "/>
								</Grid.ColumnDefinitions>
								<StackPanel Grid.Column="0">
									<TextBlock Style="{StaticResource descItems}">
										Start Time
									</TextBlock>
									<sl:TimePicker 
										Name="lockAptStartTime" 
										Value="{Binding Settings.AppointmentStartTime, Mode=TwoWay}"/>
								</StackPanel>
							
								<StackPanel Grid.Column="1">
									<TextBlock Style="{StaticResource descItems}">
										End Time
									</TextBlock>
									<sl:TimePicker
										Name="lockAptEndTime" 
										Value="{Binding Settings.AppointmentEndTime, Mode=TwoWay}"/>
								</StackPanel>
						</Grid>
						</StackPanel>
					</StackPanel>
				</StackPanel>
			</controls:PivotItem>

			<!--Pivot item three-->
			<controls:PivotItem 
				Header="Person" 
				Name="person"
				IsEnabled="{Binding Settings.CustomizeSettings}" >
				<StackPanel Margin="0,-30,0,0">
					<TextBlock Style="{StaticResource descItems}">
							Name
					</TextBlock>
					<clr:ClearableTextBox
							Name="personName"
							Text="{Binding Settings.PersonName, Mode=TwoWay}"  
							ClearButtonTemplate="{StaticResource clearX}" />

					<TextBlock Style="{StaticResource descItems}">
							Number
					</TextBlock>
					<clr:ClearableTextBox 
							Text="{Binding Settings.PersonPhoneNumber, Mode=TwoWay}" 
							Name="personPhoneNumber"
							ClearButtonTemplate="{StaticResource clearX}" />

					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<StackPanel Grid.Column="0">
							<TextBlock Style="{StaticResource descItems}">
								Phone Type
							</TextBlock>
							<sl:ListPicker 
								Name="personPhoneType"
								Margin="12,12"
								DataContext="{Binding Source={StaticResource PhoneType}}" 
								ItemsSource="{Binding Collection}">
								<sl:ListPicker.ItemTemplate>
									<DataTemplate>
										<StackPanel Orientation="Horizontal">
											<TextBlock Text="{Binding Text}" Margin="12 0 0 0"/>
										</StackPanel>
									</DataTemplate>
								</sl:ListPicker.ItemTemplate>
								
								<!--<sl:ListPicker.ItemTemplate>
									<DataTemplate>
										<StackPanel>
											<TextBlock x:Name="item" Text="{Binding Path=Text}" FontSize="26" Margin="10, 6, 0, 10" />
										</StackPanel>
									</DataTemplate>
								</sl:ListPicker.ItemTemplate>-->
							</sl:ListPicker>
						</StackPanel>
						<Button 
							Click="newPersonPhoto_Click"
							Grid.Column="1" 
							Style="{StaticResource photoStyle}">
							<Image 
								Name="PersonPhoto"
								Source="{Binding Settings.PersonPhoto, 
								Converter={StaticResource ImageConverter}}" 
								Stretch="UniformToFill" />
						</Button>
				</Grid>
				</StackPanel>
			</controls:PivotItem>
		</controls:Pivot>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
			<shell:ApplicationBar.Buttons>
				<shell:ApplicationBarIconButton IconUri="/Media/appbar.check.rest.png" 
												Text="Place Call" 
												Click="LaunchApp_Click"
												 />
			</shell:ApplicationBar.Buttons>
			<shell:ApplicationBar.MenuItems>
				<shell:ApplicationBarMenuItem Text="About" 
											  Click="LaunchAbout_Click" />
			</shell:ApplicationBar.MenuItems>
		</shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    
</phone:PhoneApplicationPage>